package cn.sylinx.common.ext.qrcode;

import java.io.File;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;

public class QrcodeTest {

	public static void main(String[] args) {
		try {

			String content = "http://www.sina.com.cn";
			String path = "/Users/han/Desktop";

			QRCodeWriter multiFormatWriter = new QRCodeWriter();
			BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, 400, 400);
			File file1 = new File(path, "baidu.jpg");
			MatrixToImageWriter.writeToFile(bitMatrix, "jpg", file1);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
